﻿//-----------------------------------------------------------------------
// <copyright file="ExceptionModel.cs" company="SLWY Enterprises">
// * Copyright (C) 2017 四川商旅无忧科技有限公司 版权所有。
// * version : 1.0
// * author  : qinchaoyue
// * FileName: LogEntry.cs
// * history : created by qinchaoyue 2017-11-09 05:19:17
// </copyright>
//-----------------------------------------------------------------------

using System.Diagnostics;

namespace Slwy.Logger.Models
{
    /// <summary>
    /// 异常日志
    /// </summary>
    public class ExceptionModel : BaseLogModel
    {
        /// <summary>
        /// 异常级别
        /// Error、Warn、Info、Debug中一种
        /// </summary>
        public string ErrorLevel { get; set; } = string.Empty;

        /// <summary>
        /// 进程ID
        /// 应用程序的进程ID，可为空
        /// </summary>
        public string ProcessId
        {
            get
            {
                try
                {
                    return Process.GetCurrentProcess().Id.ToString();
                }
                catch
                {
                    return "获取进程Id失败";
                }
            }
        }

        /// <summary>
        /// 线程ID
        /// 可为空
        /// </summary>
        public string ThreadId
        {
            get
            {
                try
                {
                    return System.Threading.Thread.CurrentThread.ManagedThreadId.ToString();
                }
                catch
                {
                    return "获取线程Id失败";
                }
            }
        }

        /// <summary>
        /// 错误码
        /// 程序自定义的错误码，某种错误指定的错误码，没有定义时为为空
        /// </summary>
        public string ErrorCode { get; set; } = string.Empty;

        /// <summary>
        /// 异常信息
        /// Exception message信息
        /// </summary>
        public string Message { get; set; } = string.Empty;

        /// <summary>
        /// 异常上下文
        /// 包括了异常堆栈信息，用于分析具体问题
        /// </summary>
        public string Context { get; set; } = string.Empty;

        /// <summary>
        /// 备用字段1
        /// </summary>
        public string Key1 { get; set; } = string.Empty;

        /// <summary>
        /// 备用字段2
        /// </summary>
        public string Key2 { get; set; } = string.Empty;

        /// <summary>
        /// 备用字段3
        /// </summary>
        public string Key3 { get; set; } = string.Empty;
    }
}
